import { ref, computed } from "vue";
import { defineStore } from "pinia";

export const useSearchStore = defineStore(
  "search",
  () => {
    const hisList = <any>ref([]);

    // 搜索历史记录
    function setHistory(newVal: Array<any>) {
      hisList.value = newVal;
    }

    // 清空历史记录
    function clearHistory() {
      hisList.value = [];
    }

    return {
      hisList,
      setHistory,
      clearHistory,
    };
  },
  {
    persist: true,
  }
);
